<!DOCTYPE html>
<meta name="viewport" content="width=device-width, user-scalable=no">
<link rel="stylesheet" type="text/css" href="resources/tablet.css">
<link rel="stylesheet" type="text/css" href="resources/transition.css">
<script src="resources/perf_test_helper.js"></script>
<style>
target {
  opacity: 0;
}
trigger + target {
  transition: none;
  opacity: 1;
}
trigger {
  display: none;
}
</style>

<container id="container"></container>

<script>
var N = PerfTestHelper.getN(1000);
var duration = 1000;
var targets = [];
var triggers = [];

for (var i = 0; i < N; i++) {
  triggers.push(document.createElement('trigger'));
  var target = document.createElement('target');
  container.appendChild(target);
  targets.push(target);
}

function startAllTransitions() {
  requestAnimationFrame(function() {
    targets.forEach(function(target, i) {
      container.insertBefore(triggers[i], target);
    });
    requestAnimationFrame(function() {
      triggers.forEach(function(trigger) {
        trigger.remove();
      })
    });
  });
}

requestAnimationFrame(startAllTransitions);
setInterval(startAllTransitions, duration);

PerfTestHelper.signalReady();
</script>
